/*
2021-8-11
https://www.acwing.com/problem/content/1092/
*/ 
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
const int N=5e4+5;
int n,t;
int f[N],q[N],w[N];

bool check(int len)
{
    f[0]=0;
    int hh=0,tt=0;
    
    for(int i=1;i<=n;i++)
    {
        if(q[hh]<i-len-1) hh++;
        f[i]=f[q[hh]]+w[i];
        while(hh<=tt && f[i]<=f[q[tt]]) tt--;
        q[++tt]=i;
    }
    
    for(int i=n-len;i<=n;i++)
        if(f[i]<=t)
            return true;
    return false;
}

int main()
{
    cin>>n>>t;
    for(int i=1;i<=n;i++) cin>>w[i];
    
    int l=0,r=n;
    
    while(l<r)
    {
        int mid=l+r>>1;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    
    cout<<r<<endl;
    
    return 0;
}

